package com.fjh.springboot_01.controller;

import com.fjh.springboot_01.pojo.Result;
import com.fjh.springboot_01.pojo.lesson.Lesson;
import com.fjh.springboot_01.service.RecommendService;
import com.fjh.springboot_01.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class RecommendController {

    @Autowired
    private RecommendService recommendService;

    @GetMapping("/lesson/recommend")
    public Result getRecommendedLessons(@RequestParam(defaultValue = "6") int limit) {
        Map<String, Object> map = ThreadLocalUtil.get();
        Integer userId = (Integer) map.get("id");
        List<Lesson> recommendations = recommendService.getRecommendedLessons(userId, limit);
        return Result.success(recommendations);
    }
} 